package org.linlinjava.litemall.db.util;

import org.springframework.data.domain.PageRequest;

/**
 * @author wj
 * @date 2021/11/4 14:26
 */
public class LgBaseInfoStatConstant {


    /**
     * 物流的状态信息,不同的物流类型对应不同的状态信息
     *
     *     购买：
     *      10-未配货
     *      11-配货中
     *      12-已配货
     *      13-未配送
     *      14-配送中
     *      15-已配送
     *     维护:
     *      20-维护中
     *      21-维护完成
     *     换货：
     *      25-开始退货
     *      26-退货完成
     *      27-开始配货
     *      28-配货完成
     *      29-开始配送
     *      30-配送完成
     *     归还:
     *      35-归还中
     *      36-归还完成
     *     退货:
     *      40-退货中
     *      41-退货成功
     *     自提:
     *      45-配货中
     *      46-配货完成
     *      47-已自提
     *
     *      特殊:
     *      80-租赁归还
     *      81-完成
     *      100-拒收
     *      101-换货拒收
     */

    //未配货
    public static final Integer BUY_UN_ALLOT=10;

    //配货中
    public static final Integer BUY_ALLOTING=11;

    //配货完成
    public static final Integer BUY_ALLOT_COMPLETE=12;

    //未配送
    public static final Integer BUY_UN_SEND=13;

    //配送中
    public static final Integer BUY_SENDING=14;

    //已配送
    public static final Integer BUY_SEND_COMPLETE=15;

    //待维护
    public static final Integer UN_MAINTAINING=19;

    //维护中
    public static final Integer MAINTAINING=20;

    //维护完成
    public static final Integer MAINTAIN_COMPLETE=21;

    //待退货
    public static final Integer CHANGE_UN_BACKING_GOODS=24;

    //退货中
    public static final Integer CHANGE_BACKING_GOODS=25;

    //退货完成
    public static final Integer CHANGE_BACK_GOODS_COMPLETE=26;

    //开始配货
    public static final Integer CHANGE_ALLOTING=27;

    //配货完成
    public static final Integer CHANGE_ALLOT_COMPLETE=28;

    //待配送
    public static final Integer CHANGE_UN_SENDING=29;

    //开始配送
    public static final Integer CHANGE_SENDING=30;

    //配送完成
    public static final Integer CHANGE_SEND_COMPLETE=31;

    //34-待归还
    public static final Integer UN_RETURNING=34;

    //35-归还中
    public static final Integer RETURNING=35;

    //36-归还完成
    public static final Integer RETURN_COMPLETE=36;


    //39-待退货
    public static final Integer BACKING_UN_GOODS=39;

    //40-退货中
    public static final Integer BACKING_GOODS=40;

    //41-退货成功
    public static final Integer BACK_GOODS_COMPLETE=41;

    //45-配货中
    public static final Integer PICK_UP_ALLOTING=45;

    //46-配货完成
    public static final Integer PICK_UP_ALLOT_COMPLETE=46;

    //47-已自提
    public static final Integer PICK_UP_COMPLETE=47;

    //80-租赁归还
    public static final Integer LEASE_BACK=80;
    //81-完成
    public static final Integer FINISH=81;



    //100-拒收
    public static final Integer REFUSE=100;

    //101-换货拒收
    public static final Integer CHANGE_REFUSE=101;

    //110-物流异常
    public static final Integer STATE_EXCEPTION=110;
    /**
     * 抢单企业微信使用-修改baseInfo状态
     * @param baseType 基本信息类型:1-购买（配货+送货）,2-维护 3-归还,4-换货（退货+配货+送货）,5-退货 8-自提配货
     * @param takeOrderType 抢单记录类型：0-配货 1-送货 2-取货 3-维护 4-医生抢单
     * @return
     */
    public static Integer getNowStat(Integer baseType,Integer takeOrderType){
        switch (baseType){
            case 1:
                switch (takeOrderType){
                    case 0:
                        //配货中
                        return BUY_ALLOTING;
                    case 1:
                        //配送中
                        return BUY_SENDING;
                    default:
                        return 0;
                }
            case 2:
                switch (takeOrderType){
                    case 3:
                        //维护中
                        return MAINTAINING;
                    default:
                        return 0;
                }
            case 3:
                switch (takeOrderType){
                    case 2:
                        //归还中
                        return RETURNING;
                    default:
                        return 0;
                }
            case 4:
                switch (takeOrderType){
                    case 0:
                        //开始配货
                        return CHANGE_ALLOTING;
                    case 1:
                        //开始配送
                        return CHANGE_SENDING;
                    case 2:
                        //退货中
                        return CHANGE_BACKING_GOODS;
                    default:
                        return 0;
                }
            case 5:
                switch (takeOrderType){
                    case 2:
                        //退货中
                        return BACKING_GOODS;
                    default:
                        return 0;
                }
            case 8:
                switch (takeOrderType){
                    case 0:
                        //配货中
                        return PICK_UP_ALLOTING;
                    default:
                        return 0;
                }
            default:
                return 0;
        }
//        return 0;
    }

    /**
     * 发货使用--变为待配送   下单等也使用
     */
    public static Integer waitToSendStat(Integer baseInfoType,Integer missionType){
        switch (baseInfoType){
            case 1:
                switch (missionType){
                    case 1:
                        return BUY_ALLOTING;
                    case 2:
                        return BUY_UN_SEND;
                }
            case 2:
                switch (missionType){
                    case 3:
                        return UN_MAINTAINING;
                }
            case 3:
                switch (missionType){
                    case 4:
                        return UN_RETURNING;
                }
            case 4:
                switch (missionType){
                    case 5:
                        return CHANGE_UN_BACKING_GOODS;
                    case 6:
                        return CHANGE_ALLOTING;
                    case 7:
                        return CHANGE_UN_SENDING;
                }
            case 5:
                switch (missionType){
                    case 4:
                        return BACKING_UN_GOODS;
                }
            case 8:
                switch (missionType){
                    case 8:
                        return PICK_UP_ALLOTING;
                }
            default:
                return 0;
        }
    }

    /**
     * 发货使用--变为配送中
     */
    public static Integer startToSendStat(Integer baseInfoType,Integer missionType){
        switch (baseInfoType){
            case 1:
                switch (missionType){
                    case 2:
                        return BUY_SENDING;
                }
            case 2:
                switch (missionType){
                    case 3:
                        return MAINTAINING;
                }
            case 3:
                switch (missionType){
                    case 4:
                        return RETURNING;
                }
            case 4:
                switch (missionType){
                    case 5:
                        return CHANGE_BACKING_GOODS;
                    case 7:
                        return CHANGE_SENDING;
                }
            case 5:
                switch (missionType){
                    case 4:
                        return BACKING_GOODS;
                }
            default:
                return 0;
        }
    }


    /**
     * 订单播报器配货使用--修改baseInfo表状态
     * @param missionType
     * @return
     */
    public static Integer annoToNowStat(Integer missionType){
        switch (missionType){
            case 1:
               return BUY_ALLOTING;
            case 4:
                return BACKING_GOODS;
            case 5:
                return CHANGE_BACKING_GOODS;
            case 6:
                return CHANGE_ALLOTING;
            case 8:
                return PICK_UP_ALLOTING;
            default:
                return 0;
        }
//        return 0;
    }

}
